package com.hsj.goldstore.mvp.model;

import android.util.Log;

import com.hsj.goldstore.base.BaseBean;
import com.hsj.goldstore.base.BaseModel;
import com.hsj.goldstore.base.ResultCallback;
import com.hsj.goldstore.utils.rxjava.ApiCaback;
import com.hsj.goldstore.utils.rxjava.ObserCallback;

import java.util.HashMap;

/**
 * Created by Administrator on 2018/3/29.
 */

public class RegistModel extends BaseModel implements IRegistModel {
    private static final String TAG = "RegistModel";

    @Override
    public void regist(String phone, String verify,
                       String pwd,  final ResultCallback callback) {
        HashMap<String, String> map = new HashMap<>();
        map.put("mobile", phone);
        map.put("verifyCode", verify);
        map.put("password", pwd);
        addSubscribe(apiStore.regist(map),new ObserCallback(new ApiCaback<BaseBean>() {
            @Override
            public void onSuccess(BaseBean data) {
                if (data.getCode() == 1001) {
                    callback.onFalure(data.getCode() , (String) data.getMsg());
                } else {
                    callback.onSuccess(data, 0, "注册成功");
                }
            }

            @Override
            public void onFailure(int code, String msg) {
                callback.onFalure(code,msg);
            }
        }));
    }

    @Override
    public void forgetPassword(String phone, String verify, String pwd, ResultCallback callback) {

}

    @Override
    public void modifyPassword(String phone, String verify, String pwd, ResultCallback callback) {

    }
}
